package com.rui.service.impl;

import com.rui.domain.*;
import com.rui.mapper.AcademicMapper;
import com.rui.mapper.MyCustomMapper;
import com.rui.mapper.StudentMapper;
import com.rui.service.AcademicService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("academicService")
public class AcademicServiceImpl implements AcademicService {

    private final String LOGGER_STATUS="已阅";

    @Autowired
    private AcademicMapper academicMapper;

    @Autowired
    private MyCustomMapper customMapper;

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Academic findAcademicByJobNo(String jobNo) {
        Academic academic = academicMapper.selectByPrimaryKey(jobNo);
        return academic;
    }

    @Override
    public boolean updateAcademic(Academic academic) {
        int row = academicMapper.updateByPrimaryKeySelective(academic);
        if (row > 0) {
            return true;
        }
        return false;
    }

    @Override
    public List<InternshipVO> findInternshipByYear(String year) {
        return customMapper.findAllInternship(year);
    }

    @Override
    public List<CountDTO> getDevelopmentLanguageCount(int year) {
        return customMapper.getDevelopmentLanguageCount(year);
    }


    @Override
    public List<CountDTO> getDataBaseCount(int year) {
        return customMapper.getDataBaseCount(year);
    }

    @Override
    public SalaryVO getSalaryCount(int year) {
        return customMapper.getSalaryCount(year);
    }

    @Override
    public Long getStudentTotal(int year) {
        StudentExample example = new StudentExample();
        StudentExample.Criteria criteria = example.createCriteria();
        criteria.andGradeEqualTo(String.valueOf(year));
        long count = studentMapper.countByExample(example);
        return count;
    }

    @Override
    public Long getInternshipCount(int year) {
        return customMapper.getInternshipCount(year);
    }

    @Override
    public List<InternshipLoggerInfoVO> getInternshipLoggerList(int year) {
        QueryInternshipLoggerDTO dto = new QueryInternshipLoggerDTO(LOGGER_STATUS,year);
        return customMapper.getInternshipLoggerList(dto);
    }

    @Override
    public List<InternshipLoggerInfoVO> findInternshipLoggerByStuNos(String[] stuNoArray) {
        return customMapper.findInternshipLoggerByStuNos(stuNoArray);
    }

    @Override
    public List<CountDTO> getJobDevelopmentLanguageCount(int year) {
        return customMapper.getJobDevelopmentLanguageCount(year);
    }

    @Override
    public List<CountDTO> getJobDataBaseCount(int year) {
        return customMapper.getJobDataBaseCount(year);
    }

    @Override
    public SalaryVO getJobSalaryCount(int year) {
        return customMapper.getJobSalaryCount(year);
    }

    @Override
    public Long getJobCount(int year) {
        return customMapper.getJobCount(year);
    }
}
